/*
 * Node.h
 *
 *  Created on: May 29, 2011
 *      Author: gilang
 */

#ifndef NODE_H_
#define NODE_H_
#include "Point.h"
#include "SinglePoint.h"
#include "DoublePoint.h"
#include <iomanip>

class Node {
private:
	Node *next;
	Node *before;
	Point point;
public:
	Node(){
		next=NULL;
		before=NULL;
	}
	Node(const Node &n){
		this->point=n.point;
		this->next=n.next;
		this->before=n.before;
	}
	Node(double x){
		point=SinglePoint(x);
	}
	Node(double x,double y,double z){
		point=Point(x,y,z);
	}
	Node(double x,double y){
		point=DoublePoint(x,y);
	}

	void setBefore(Node *before){this->before=before;}
	void setNext(Node *next){this->next=next;}
	void setPoint(const Point p){this->point=p;}
	Point & getPoint(){return point;}
	Node getNext() {
		if(next==NULL){
			next=new Node();
			setNext(next);
		}
		next->setBefore(this);
		return *next;
	}

	Node getBefore(){

		return *before;
	}

	virtual ~Node(){}
};

#endif /* NODE_H_ */
